The goal of this notebook is to explore the impact of the upcoming sector expiration wave on April / May, especially when considering the ones with V1 proofs.
%load_ext autotime
%load_ext autoreload
%autoreload 2
time: 7.86 ms (started: 2021-08-15 00:11:27 +00:00)
# External dependences
import pandas as pd
import numpy as np
import plotly.express as px
from prophet import Prophet
import matplotlib.pyplot as plt
# Move path to parent folder
import sys
sys.path.insert(1, '../')
import plotly
plotly.offline.init_notebook_mode()
time: 885 ms (started: 2021-08-15 00:11:27 +00:00)
# Create a connection object from a conn string
from filecoin_metrics.connection import get_connection, get_connection_string
conn_string = get_connection_string('../config/sentinel-conn-string.txt')
connection = get_connection(conn_string)
time: 1.45 s (started: 2021-08-15 00:11:28 +00:00)
QUERY = """
/* Get the last state of the sectors */
with sector_states as (
select
msi.*,
max(msi.height) over (partition by msi.sector_id, msi.miner_id) as max_height
from miner_sector_infos msi
where msi.activation_epoch > 0
and msi.expiration_epoch > msi.height /* Get only active sectors */
order by max_height
)
select
count(*) as sector_count,
sum(ss.initial_pledge::numeric) / 1e18 as initial_pledge_in_fil,
count(*) * 32 as network_power_in_gb,
date_trunc('DAY', to_timestamp(height_to_unix(ss.activation_epoch))) as activation_date,
date_trunc('DAY', to_timestamp(height_to_unix(ss.expiration_epoch))) as expiration_date
from sector_states as ss
where ss.max_height = ss.height /* get the last state of the info */
group by activation_date, expiration_date
order by activation_date, expiration_date
"""
query_df = (pd.read_sql(QUERY, connection)
.assign(network_power_in_pib=lambda df: df.network_power_in_gb / (1024 ** 2))
.assign(initial_pledge_in_thousand_fil=lambda df: df.initial_pledge_in_fil / 1000))
time: 4min 40s (started: 2021-08-15 00:11:30 +00:00)
# Maximum date for V1 sectors
UPGRADE_DATE = '2020-11-25 00:00:00'
metrics = {'is_v1': lambda x: x['activation_date'] < UPGRADE_DATE}
query_df = query_df.assign(**metrics)
time: 16.2 ms (started: 2021-08-15 00:16:10 +00:00)
def resample_and_bar_plot(df, resample_rule, time_column, value_column, title, **kwargs):
fig_df = df.resample(resample_rule, on=time_column, label='left').sum()
fig = px.bar(fig_df.reset_index(),
x=time_column,
y=value_column,
title=title,
**kwargs)
return fig
def resample_and_bar_plot_relative(df, resample_rule, time_column, value_column, title, **kwargs):
fig_df = df.resample(resample_rule, on=time_column, label='left').sum()
y = fig_df.groupby(time_column).sum()
fig_df /= y
fig = px.bar(fig_df.reset_index(),
x=time_column,
y=value_column,
title=title,
**kwargs)
return fig
time: 13.2 ms (started: 2021-08-15 00:16:10 +00:00)
df = query_df.copy()
print("Basic stats")
print("---")
print(f"Total sectors (#): {df.sector_count.sum()}")
print(f"Raw bytes power (PiB): {df.network_power_in_gb.sum() / (1024 ** 2) :.3g}")
print(f"Initial pledge (FIL): {df.initial_pledge_in_fil.sum()}")
print("---")
Basic stats --- Total sectors (#): 75376301 Raw bytes power (PiB): 2.3e+03 Initial pledge (FIL): 22521296.37945206 --- time: 14.1 ms (started: 2021-08-15 00:16:11 +00:00)
resample_rule = '1m'
time_column = 'expiration_date'
value_column = 'sector_count'
title = 'Count of Expiring Sectors (#)'
groups = [pd.Grouper(key='expiration_date', freq=resample_rule),
'is_v1']
fig_df = (df.groupby(groups)
.sum()
)
fig = px.bar(fig_df.reset_index(),
x=time_column,
y=value_column,
color='is_v1',
title=title)
fig.show()
time: 369 ms (started: 2021-08-15 00:16:11 +00:00)
resample_rule = '1d'
time_column = 'expiration_date'
value_column = 'sector_count'
title = 'Count of Expiring Sectors Before 15Jun2021 (log #)'
groups = [pd.Grouper(key='expiration_date', freq=resample_rule),
'is_v1']
fig_df = (df.query("expiration_date < '2021-06-15 00:00+00:00'")
.groupby(groups)
.sum()
.reset_index()
)
if fig_df.empty:
print('WARNING: DataFrame is Empty')
else:
fig = px.bar(fig_df,
x=time_column,
y=value_column,
facet_row=fig_df.is_v1,
title=title,
log_y=True)
fig.show()
WARNING: DataFrame is Empty time: 29.2 ms (started: 2021-08-15 00:16:11 +00:00)
sector_count = df.sector_count.sum()
v1_count = df.query("is_v1 == True").sector_count.sum()
v1_6mo_count = (df.query("is_v1 == True & expiration_date < '2021-06-01 00:00+00:00'")
.sector_count
.sum())
v1_12mo_count = (df.query("is_v1 == True & expiration_date < '2021-12-01 00:00+00:00' & expiration_date >= '2021-06-01 00:00+00:00'")
.sector_count
.sum())
v1_18mo_count = (df.query("is_v1 == True & expiration_date < '2022-06-01 00:00+00:00' & expiration_date >= '2021-12-01 00:00+00:00'")
.sector_count
.sum())
print("---")
print(f"Total sectors (#): {sector_count}")
print(f"V1 sectors (#): {v1_count}")
print(f"V1 sectors share (%): {v1_count / sector_count :.1%}")
print("---")
print(f"6mo V1 sectors share (%) of total sectors: {v1_6mo_count / sector_count :.2%}")
print(f"12mo V1 sectors share (%) of total sectors: {v1_12mo_count / sector_count :.2%}")
print(f"18mo V1 sectors share (%) of total sectors: {v1_18mo_count / sector_count :.2%}")
print("---")
print(f"6mo V1 sectors share (%) of total sectors: {v1_6mo_count / v1_count :.2%}")
print(f"12mo V1 sectors share (%) of total sectors: {v1_12mo_count / v1_count :.2%}")
print(f"18mo V1 sectors share (%) of total sectors: {v1_18mo_count / v1_count :.2%}")
print("---")
--- Total sectors (#): 75376301 V1 sectors (#): 1189468 V1 sectors share (%): 1.6% --- 6mo V1 sectors share (%) of total sectors: 0.00% 12mo V1 sectors share (%) of total sectors: 0.00% 18mo V1 sectors share (%) of total sectors: 1.58% --- 6mo V1 sectors share (%) of total sectors: 0.00% 12mo V1 sectors share (%) of total sectors: 0.00% 18mo V1 sectors share (%) of total sectors: 100.00% --- time: 32.7 ms (started: 2021-08-15 00:16:11 +00:00)
resample_rule = '1m'
time_column = 'expiration_date'
value_column = 'sector_count'
title = 'Upcoming Sector Expiration Count, grouped by sector version (#)'
groups = [pd.Grouper(key='expiration_date', freq=resample_rule),
'is_v1']
fig_df = (df.groupby(groups)
.sum()
.reset_index()
)
fig = px.bar(fig_df.reset_index(),
x=time_column,
y=value_column,
facet_row='is_v1',
title=title)
fig.show()
time: 97 ms (started: 2021-08-15 00:16:11 +00:00)
resample_rule = '1w'
time_column = 'activation_date'
value_column = 'sector_count'
title = 'Activated Sector Count, grouped by sector version (#)'
groups = [pd.Grouper(key='activation_date', freq=resample_rule),
'is_v1']
fig_df = (df.groupby(groups)
.sum()
.reset_index()
)
fig = px.bar(fig_df.reset_index(),
x=time_column,
y=value_column,
facet_row='is_v1',
title=title)
fig.show()
time: 101 ms (started: 2021-08-15 00:16:11 +00:00)
rename_cols = {'activation_date': 'ds',
'sector_count': 'y'}
proj_df = (df.resample("1d", on="activation_date")
.sector_count
.sum()
.reset_index()
.rename(columns=rename_cols)
.assign(ds=lambda df: df.ds.dt.tz_localize(None))
.assign(y=lambda df: df.y.cumsum() / (32 * 1024 * 1024)))
m = Prophet(changepoint_prior_scale=0.4)
m.fit(proj_df)
future = m.make_future_dataframe(periods=60)
forecast = m.predict(future)
fig = m.plot(forecast, figsize=(10, 4))
plt.title('Past and Forecasted RB Storage Power')
plt.xlabel("Time")
plt.ylabel("Total RB Storage Power (EiB)")
plt.show()
INFO:prophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this. INFO:prophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
Initial log joint probability = -35.0067
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
99 1139.31 0.0776257 508.746 1 1 123
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
199 1225.68 0.00508029 309.335 1 1 232
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
299 1238.37 0.000379716 298.079 1 1 343
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
399 1262.26 0.0224918 135.873 1 1 458
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
499 1267.26 0.0081595 107.049 1 1 576
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
599 1270.63 0.000196035 73.6143 1 1 683
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
699 1273.44 0.00120385 70.3905 1 1 800
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
799 1277.43 0.0194561 254.225 1 1 913
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
899 1280.91 0.000101534 34.8788 1 1 1023
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
955 1281.3 4.66146e-05 12.3742 2.074e-06 0.001 1129 LS failed, Hessian reset
999 1281.49 0.00228042 59.0196 0.8704 0.8704 1180
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1099 1281.9 0.000962236 32.5382 1 1 1300
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1199 1282.11 0.000211426 64.755 0.3577 0.3577 1421
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1299 1282.5 0.0338419 69.001 1 1 1536
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1350 1282.63 5.84207e-06 13.6061 4.664e-07 0.001 1642 LS failed, Hessian reset
1371 1282.64 9.25564e-05 26.4229 1.04e-05 0.001 1718 LS failed, Hessian reset
1380 1282.65 4.07281e-06 9.32619 3.153e-07 0.001 1767 LS failed, Hessian reset
1399 1282.66 1.65302e-05 20.2031 0.7108 0.7108 1790
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1499 1282.72 0.000106485 22.9923 0.3017 1 1921
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1599 1282.76 1.03062e-05 22.9483 4.267e-07 0.001 2085 LS failed, Hessian reset
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1660 1282.77 8.98534e-06 18.7586 7.626e-07 0.001 2210 LS failed, Hessian reset
1699 1282.77 0.000284016 9.95813 1 1 2257
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1799 1283.05 0.0144849 84.4298 1 1 2367
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1899 1283.14 0.000982855 40.9433 1 1 2487
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
1937 1283.15 2.86309e-05 10.0694 2.102e-06 0.001 2579 LS failed, Hessian reset
1999 1283.15 0.000181262 9.03113 1 1 2662
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
2022 1283.15 4.73533e-06 10.6747 3.908e-07 0.001 2730 LS failed, Hessian reset
2039 1283.15 3.41385e-07 5.38306 0.2688 1 2752
Optimization terminated normally:
Convergence detected: relative gradient magnitude is below tolerance
time: 3.41 s (started: 2021-08-15 00:16:11 +00:00)
rename_cols = {'activation_date': 'ds',
'sector_count': 'y'}
proj_df = (df.query("activation_date > '2020-11-01 00:00+00:00'")
.resample("1d", on="activation_date")
.sector_count
.sum()
.reset_index()
.rename(columns=rename_cols)
.assign(ds=lambda df: df.ds.dt.tz_localize(None)))
m = Prophet(changepoint_prior_scale=0.2)
m.fit(proj_df)
future = m.make_future_dataframe(periods=60)
forecast = m.predict(future)
fig = m.plot(forecast, figsize=(10, 4))
plt.title('Past and Forecasted Daily New Sectors')
plt.xlabel("Time")
plt.ylabel("Daily New Sectors (#)")
plt.show()
INFO:prophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this. INFO:prophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
Initial log joint probability = -10.9238
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
99 549.154 0.0407864 65.4551 1 1 118
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
194 555.847 0.000701584 24.9714 6.201e-06 0.001 270 LS failed, Hessian reset
199 556.401 0.00800813 23.3793 1 1 276
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
299 557.626 0.0933311 111.273 0.5942 0.5942 396
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
380 558.144 0.000464055 39.9562 1.644e-05 0.001 538 LS failed, Hessian reset
399 558.153 2.64097e-06 19.933 0.1578 0.6252 564
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
428 558.161 0.000139582 15.9692 5.699e-06 0.001 633 LS failed, Hessian reset
499 558.178 2.55309e-05 19.4393 0.5963 0.5963 722
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
599 558.776 0.00206134 26.1339 1 1 843
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
668 559.013 0.000937077 25.076 4.824e-05 0.001 957 LS failed, Hessian reset
699 559.068 0.000163952 18.3926 0.3772 1 989
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
767 559.077 3.50342e-06 21.1724 1.65e-07 0.001 1120 LS failed, Hessian reset
785 559.077 9.33083e-08 17.8457 0.3309 1 1145
Optimization terminated normally:
Convergence detected: relative gradient magnitude is below tolerance
time: 2.13 s (started: 2021-08-15 00:16:15 +00:00)
rename_cols = {'activation_date': 'ds',
'sector_count': 'y'}
proj_df = (df.query("activation_date > '2020-11-01 00:00+00:00' & activation_date < '2021-03-01 00:00+00:00'")
.resample("1d", on="activation_date")
.sector_count
.sum()
.reset_index()
.rename(columns=rename_cols)
.assign(ds=lambda df: df.ds.dt.tz_localize(None)))
m = Prophet(changepoint_prior_scale=0.2)
m.fit(proj_df)
future = m.make_future_dataframe(periods=90)
forecast = m.predict(future)
fig = m.plot(forecast, figsize=(10, 4))
plt.title('Past and Forecasted Daily New Sectors without March data')
plt.xlabel("Time")
plt.ylabel("Daily New Sectors (#)")
plt.show()
INFO:prophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this. INFO:prophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
Initial log joint probability = -4.476
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
72 151.528 0.00255944 21.4481 7.658e-05 0.001 120 LS failed, Hessian reset
99 151.713 0.000149277 17.1013 2.201 0.2201 163
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
144 151.717 0.000179243 13.4875 8.639e-06 0.001 264 LS failed, Hessian reset
199 151.718 9.43985e-06 17.6273 1 1 342
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
226 151.733 5.13839e-05 17.9329 3.145e-06 0.001 416 LS failed, Hessian reset
252 151.733 9.53697e-09 15.6199 0.06896 0.06896 461
Optimization terminated normally:
Convergence detected: absolute parameter change was below tolerance
time: 2.2 s (started: 2021-08-15 00:16:17 +00:00)
rename_cols = {'activation_date': 'ds',
0: 'y'}
proj_df = (df.query("activation_date > '2020-11-01 00:00+00:00'")
.resample("1d", on="activation_date")
.apply(lambda x: (x.initial_pledge_in_fil / x.sector_count).mean())
.reset_index()
.rename(columns=rename_cols)
.assign(ds=lambda df: df.ds.dt.tz_localize(None))
)
m = Prophet(changepoint_prior_scale=0.2)
m.fit(proj_df)
future = m.make_future_dataframe(periods=60)
forecast = m.predict(future)
fig = m.plot(forecast, figsize=(10, 4))
plt.title('Past and Forecasted Initial Pledge per Sector')
plt.xlabel("Time")
plt.ylabel("Mean Initial Pledge per Sector (FIL)")
plt.show()
INFO:prophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this. INFO:prophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
Initial log joint probability = -4.78487
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
65 327.656 0.00252298 45.1024 0.0001365 0.001 114 LS failed, Hessian reset
99 328.965 0.00355851 19.5719 0.4846 0.04846 152
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
130 329.659 0.00115403 37.5926 4.048e-05 0.001 222 LS failed, Hessian reset
199 330.489 0.000569071 19.1283 1 1 314
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
299 330.647 0.00112969 15.5719 0.7325 0.7325 442
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
399 332.004 0.0296414 20.2757 1 1 562
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
408 332.203 0.00103403 33.3078 5.548e-05 0.001 603 LS failed, Hessian reset
499 332.567 0.000583614 14.6775 0.4051 1 717
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
599 332.795 2.52175e-06 14.3895 0.8679 0.8679 847
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
615 332.796 5.62906e-08 13.4072 0.1989 1 868
Optimization terminated normally:
Convergence detected: relative gradient magnitude is below tolerance
time: 2.17 s (started: 2021-08-15 00:16:19 +00:00)
m.fit
<bound method Prophet.fit of <prophet.forecaster.Prophet object at 0x7f2bc5776ee0>>
time: 23.4 ms (started: 2021-08-15 00:16:21 +00:00)
resample_rule = '7d'
time_column = 'activation_date'
value_column = 'sector_count'
title = 'Count of Sector Activation Date (#)'
groups = [pd.Grouper(key='activation_date', freq=resample_rule),
pd.Grouper(key='expiration_date', freq=resample_rule)]
fig_df = df.groupby(groups).sum().reset_index()
px.density_heatmap(fig_df,
x='activation_date',
y='expiration_date',
z='sector_count')
time: 121 ms (started: 2021-08-15 00:16:21 +00:00)
resample_rule = '1d'
time_column = 'activation_date'
value_column = 'sector_count'
title = 'Count of Sector Activation Date (#)'
groups = [pd.Grouper(key='activation_date', freq=resample_rule),
pd.Grouper(key='expiration_date', freq=resample_rule)]
fig_df = df.groupby(groups).sum().reset_index()
fig = px.density_contour(fig_df,
x='activation_date',
y='expiration_date',
z='sector_count',
histfunc='sum')
fig.show()
time: 421 ms (started: 2021-08-15 00:16:21 +00:00)
sector_count = df.initial_pledge_in_fil.sum()
v1_count = df.query("is_v1 == True").initial_pledge_in_fil.sum()
v1_6mo_count = (df.query("is_v1 == True & expiration_date < '2021-06-01 00:00+00:00'")
.initial_pledge_in_fil
.sum())
v1_12mo_count = (df.query("is_v1 == True & expiration_date < '2021-12-01 00:00+00:00' & expiration_date >= '2021-06-01 00:00+00:00'")
.initial_pledge_in_fil
.sum())
v1_18mo_count = (df.query("is_v1 == True & expiration_date < '2022-06-01 00:00+00:00' & expiration_date >= '2021-12-01 00:00+00:00'")
.initial_pledge_in_fil
.sum())
print("---")
print(f"Total collateral (Million FIL): {sector_count / 1e6 :.3g}")
print(f"V1 collateral (Million FIL): {v1_count / 1e6 :.3g}")
print(f"V1 sectors share (%): {v1_count / sector_count :.1%}")
print("---")
print(f"6mo V1 sectors share (%) of total collateral: {v1_6mo_count / sector_count :.2%}")
print(f"12mo V1 sectors share (%) of total collateral: {v1_12mo_count / sector_count :.2%}")
print(f"18mo V1 sectors share (%) of total collateral: {v1_18mo_count / sector_count :.2%}")
print("---")
print(f"6mo V1 sectors share (%) of total collateral: {v1_6mo_count / v1_count :.2%}")
print(f"12mo V1 sectors share (%) of total collateral: {v1_12mo_count / v1_count :.2%}")
print(f"18mo V1 sectors share (%) of total collateral: {v1_18mo_count / v1_count :.2%}")
print("---")
--- Total collateral (Million FIL): 22.5 V1 collateral (Million FIL): 0.376 V1 sectors share (%): 1.7% --- 6mo V1 sectors share (%) of total collateral: 0.00% 12mo V1 sectors share (%) of total collateral: 0.00% 18mo V1 sectors share (%) of total collateral: 1.67% --- 6mo V1 sectors share (%) of total collateral: 0.00% 12mo V1 sectors share (%) of total collateral: 0.00% 18mo V1 sectors share (%) of total collateral: 100.00% --- time: 36.4 ms (started: 2021-08-15 00:16:22 +00:00)
resample_rule = '1m'
time_column = 'expiration_date'
value_column = 'initial_pledge_in_fil'
title = 'Initial Pledge (FIL) of Expiring Sectors (#)'
groups = [pd.Grouper(key='expiration_date', freq=resample_rule),
'is_v1']
fig_df = (df.groupby(groups)
.sum()
)
fig = px.bar(fig_df.reset_index(),
x=time_column,
y=value_column,
color='is_v1',
title=title)
fig.show()
time: 167 ms (started: 2021-08-15 00:16:22 +00:00)
resample_rule = '1m'
time_column = 'expiration_date'
value_column = 'initial_pledge_in_fil'
title = 'Initial Pledge (FIL) of Expiring Sectors, grouped by Sector Version'
groups = [pd.Grouper(key='expiration_date', freq=resample_rule),
'is_v1']
fig_df = (df.groupby(groups)
.sum()
.reset_index()
)
fig = px.bar(fig_df,
x=time_column,
y=value_column,
facet_col='is_v1',
title=title)
fig.show()
time: 105 ms (started: 2021-08-15 00:16:22 +00:00)
resample_rule = '1m'
time_column = 'activation_date'
value_column = ['initial_pledge_in_thousand_fil']
title = 'Sum of Initial Pledge (FIL) across activation dates'
resample_and_bar_plot(df, resample_rule, time_column, value_column, title).show()
time: 87.4 ms (started: 2021-08-15 00:16:22 +00:00)
resample_rule = '1m'
time_column = 'expiration_date'
value_column = 'network_power_in_pib'
title = 'RB Network Power (PiB) of Expiring Sectors (#)'
groups = [pd.Grouper(key='expiration_date', freq=resample_rule),
'is_v1']
fig_df = (df.groupby(groups)
.sum()
)
fig = px.bar(fig_df.reset_index(),
x=time_column,
y=value_column,
color='is_v1',
title=title)
fig.show()
time: 95.1 ms (started: 2021-08-15 00:16:22 +00:00)
resample_rule = '1m'
time_column = 'expiration_date'
value_column = 'network_power_in_pib'
title = 'RB Network Power (PiB) of Expiring Sectors, grouped by Sector Version'
groups = [pd.Grouper(key='expiration_date', freq=resample_rule),
'is_v1']
fig_df = (df.groupby(groups)
.sum()
.reset_index()
)
fig = px.bar(fig_df,
x=time_column,
y=value_column,
facet_col='is_v1',
title=title)
fig.show()
time: 102 ms (started: 2021-08-15 00:16:22 +00:00)
resample_rule = '1m'
time_column = 'activation_date'
value_column = ['network_power_in_pib']
title = 'Sum of RB Network Power (PiB) across activation dates'
resample_and_bar_plot(df, resample_rule, time_column, value_column, title).show()
time: 79.3 ms (started: 2021-08-15 00:16:22 +00:00)